﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace NIP.Speech.Dialog.States
{
    public class DialogStateBase: IDialogState
    {



        public DialogStateBase()
        {
            Type = DialogStateType.IdleDialogState;
            IsControlState = false;
            DefaultAbortNextState = DialogStateType.IdleDialogState;
            DefaultNextState = DialogStateType.UnChanged;
            NextState = DialogStateType.UnChanged;
            IsRepeatable = false;
            DefaultSpeechResponse = "Sorry I didn't catch that, could you please repeat a little louder?";
            para = new StateInputParameter();
        }

        public DialogStateBase(DialogStateType aType)
        {
            

            Type = aType;
            IsControlState = false;
            DefaultAbortNextState = DialogStateType.IdleDialogState;
            NextState = DialogStateType.IdleDialogState;
            IsRepeatable = true;
            para = new StateInputParameter();
            DefaultSpeechResponse = "Sorry I didn't catch that, could you please repeat a little louder?";
            switch (Type)
            {
                case DialogStateType.SessionAwaitingCommandDialogState:
                    IsControlState = true;
                    break;
                case DialogStateType.Action_In_Progress:
                    NextState = DialogStateType.SessionAwaitingCommandDialogState;
                    DefaultAbortNextState = DialogStateType.SessionAwaitingCommandDialogState;
                    break;
                case DialogStateType.Session_Initiated:
                    NextState = DialogStateType.SessionAwaitingCommandDialogState;
                    break;
            }
           
        }

        
        /// <summary>
        /// Needs to be overriden to work
        /// </summary>
        /// <returns></returns>
        public bool PreConditionCheck()
        {
            return false;
        }
        public void OnReady()
        {
            
        }

        public  StateInputParameter para { set; get; }

        public bool IsReady { set; get; }

        public DialogStateType Type
        {
            set;
            get;
        }

        public string Name
        {
            set;
            get;
        }

        public string DefaultSpeechResponse { set; get; }

        public bool IsControlState
        {
            set;
            get;
        }

        public DialogStateType DefaultAbortNextState
        {
            set;
            get;
        }

        public DialogStateType NextState
        {
            set;
            get;
        }

        public bool IsRepeatable
        {
            set;
            get;
        }

        public EventArgs.StateStatusEventArgs VoiceCommandResponse(string recognizedString)
        {
            throw new NotImplementedException();
        }


        public EventArgs.StateStatusEventArgs VoiceCommandResponse(Dictionary<string, string> recognizedText)
        {
            //throw new NotImplementedException();
            return new EventArgs.StateStatusEventArgs();
        }


        public DialogStateType DefaultNextState
        {
            get;
            set;
        }
    }
}
